import java.io.*;
import java.sql.*;
import javax.servlet.http.*;

public class StudentMessage extends HttpServlet
{
  String student_id="";
	String college_code ="";
	String message="";
	
    @Override
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException
  {

     try
       {
    student_id=request.getParameter("student_id");

         response.setContentType("text/html");
         PrintWriter out=response.getWriter();


        Class.forName("oracle.jdbc.driver.OracleDriver");

         Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","pac","mca"); 

         Statement stmt=con.createStatement();
         
             ResultSet rs = stmt.executeQuery("SELECT *from message_stu WHERE student_id='"+student_id+"'");

             
         if(rs.next())

         {
            student_id=rs.getString(1);
            college_code=rs.getString(2);
	   message=rs.getString(3);
        }
            


        out.println("<html>");
      out.println("<body bgcolor='FFCC00'>"); 
             out.println("<center>");
	
        
      out.println("<h1>message </h1></center>");
     out.println("<font size='6'>To:");
     out.println("</font><font color='white'size='6'>");
     out.println(student_id);
      out.println("</font><br><br><br><br><br><center><font size='6'>");
         out.println(message);     
         out.println("</center><br><br><br>");
         out.println("<br><br><br>");
         out.println("<br><br><br>");
 out.println("<font size='6'><valign='bottom'>");
 out.println("From:");
 out.println("<font color='white'>");
 out.println(college_code);
        
     
     out.println("</font></valign>");
     out.println("</body>");

     out.println("</html>");   
    
 }
         
     
 
    catch(Exception e)
       {
      
        // response.sendError(505,e.getMessage());
         e.printStackTrace();       
}   

  }

}  

 